package org.persistente.xml;

import java.io.ByteArrayInputStream;
import java.io.InputStream;

/**
 *
 * @author philipe
 */
public class Test {
    
    static class Child{
        public Integer id;
        public String name;
    }
    
    static class City{
        public Integer id;
        public String name;
        public String state;
    }
    
    
    static class Person{
        public Integer id;
        public String name;
        public Child[] children;
        public City city;
        public String familyName;
    }
    
    public static void main(String[] a){     
        
                
        String s = "<people><person><family-name>Silva</family-name><id>2</id><name>Fulano</name><city><id>5</id><name>Tubarão</name><state>SC</state></city><children><child><id>8</id><name>Ciclano</name></child><child><id>9</id><name>Beltrano</name></child></children></person><person><id>12</id><name>Fulano2</name><city><id>15</id><name>Laguna</name><state>SC</state></city><children><child><id>18</id><name>Ciclano2</name></child><child><id>19</id><name>Beltrano2</name></child></children><family-name>Souza</family-name></person></people>";
        InputStream is = new ByteArrayInputStream(s.getBytes());
        
        XmlParser.parseList(is, Person.class, new Callback<Person>() {

            public void execute(Person p) {
                System.out.println(p);
                System.out.println(XmlBuilder.toXml(p));
            }
        });
                
        
        
    }
    
    
    
}
